/*
 * @Author: yuanweijiang
 * @Date: 2024-04-23 15:44:13
 * @LastEditors: yuanweijiang
 */
import request from '/@/utils/request';

export const pageList = (data?: Object) => {
	return request({
		url: '/system/menu/tree',
		method: 'post',
		data,
	});
};

export const info = (data) => {
	return request({
		url: '/system/menu/getMenuById',
		method: 'post',
		data,
	});
};

export const save = (data: Object) => {
	return request({
		url: '/system/menu',
		method: 'post',
		data: data,
	});
};

export const putObj = (data: Object) => {
	return request({
		url: '/system/menu/update',
		method: 'post',
		data: data,
	});
};

export const addObj = (data: Object) => {
	return request({
		url: '/system/menu/add',
		method: 'post',
		data: data,
	});
};

export const delObj = (id: string) => {
	return request({
		url: '/system/menu/' + id,
		method: 'delete',
	});
};

/**
 * 后端控制路由，isRequestRoutes 为 true，则开启后端控制路由
 * @method getAdminMenu 获取后端动态路由菜单(admin)
 */
export function useMenuApi() {
	return {
		getAdminMenu: (obj?: object) => {
			return request({
				url: '/system/menu/userMenu',
				method: 'post',
				data: obj ? obj : {},
			});
		},
	};
}
